//
// Pipe.cpp
//
// $Id: //poco/1.4/Foundation/src/Pipe.cpp#1 $
//
// Library: Foundation
// Package: Processes
// Module:  Pipe
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier:	BSL-1.0
//


#include "Poco/Pipe.h"


namespace Poco {


Pipe::Pipe():
	m_pImpl(new PipeImpl)
{
}

	
Pipe::Pipe(const Pipe& pipe):
	m_pImpl(pipe.m_pImpl)
{
	m_pImpl->duplicate();
}


Pipe::~Pipe()
{
	m_pImpl->release();
}


Pipe& Pipe::operator = (const Pipe& pipe)
{
	if (this != &pipe)
	{
		m_pImpl->release();
		m_pImpl = pipe.m_pImpl;
		m_pImpl->duplicate();
	}
	return *this;
}


void Pipe::close(CloseMode mode)
{
	switch (mode)
	{
	case CLOSE_READ:
		m_pImpl->closeRead();
		break;
	case CLOSE_WRITE:
		m_pImpl->closeWrite();
		break;
	default:
		m_pImpl->closeRead();
		m_pImpl->closeWrite();
		break;
	}
}


} // namespace Poco

// 编译需要

#if defined(POCO_OS_FAMILY_UNIX)
#include "PipeImpl_POSIX.cpp"
#endif


